/**
 * <copyright>
 * </copyright>
 *
 */
package de.sabram.upb.specs.lido.impl;

import de.sabram.upb.specs.lido.AttrDefsOpt;
import de.sabram.upb.specs.lido.LidoPackage;
import de.sabram.upb.specs.lido.SymbolDefId;
import de.sabram.upb.specs.lido.SymbolDefIds;
import de.sabram.upb.specs.lido.TypeId;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Symbol Def Ids</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SymbolDefIdsImpl#getTypeId <em>Type Id</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SymbolDefIdsImpl#getAttrDefsOpt <em>Attr Defs Opt</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SymbolDefIdsImpl#getSymbolDefIds <em>Symbol Def Ids</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SymbolDefIdsImpl extends TermSpecImpl implements SymbolDefIds
{
  /**
   * The cached value of the '{@link #getTypeId() <em>Type Id</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTypeId()
   * @generated
   * @ordered
   */
  protected TypeId typeId;

  /**
   * The cached value of the '{@link #getAttrDefsOpt() <em>Attr Defs Opt</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAttrDefsOpt()
   * @generated
   * @ordered
   */
  protected AttrDefsOpt attrDefsOpt;

  /**
   * The cached value of the '{@link #getSymbolDefIds() <em>Symbol Def Ids</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSymbolDefIds()
   * @generated
   * @ordered
   */
  protected EList<SymbolDefId> symbolDefIds;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SymbolDefIdsImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LidoPackage.Literals.SYMBOL_DEF_IDS;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TypeId getTypeId()
  {
    return typeId;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTypeId(TypeId newTypeId, NotificationChain msgs)
  {
    TypeId oldTypeId = typeId;
    typeId = newTypeId;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.SYMBOL_DEF_IDS__TYPE_ID, oldTypeId, newTypeId);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTypeId(TypeId newTypeId)
  {
    if (newTypeId != typeId)
    {
      NotificationChain msgs = null;
      if (typeId != null)
        msgs = ((InternalEObject)typeId).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SYMBOL_DEF_IDS__TYPE_ID, null, msgs);
      if (newTypeId != null)
        msgs = ((InternalEObject)newTypeId).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SYMBOL_DEF_IDS__TYPE_ID, null, msgs);
      msgs = basicSetTypeId(newTypeId, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.SYMBOL_DEF_IDS__TYPE_ID, newTypeId, newTypeId));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public AttrDefsOpt getAttrDefsOpt()
  {
    return attrDefsOpt;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetAttrDefsOpt(AttrDefsOpt newAttrDefsOpt, NotificationChain msgs)
  {
    AttrDefsOpt oldAttrDefsOpt = attrDefsOpt;
    attrDefsOpt = newAttrDefsOpt;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.SYMBOL_DEF_IDS__ATTR_DEFS_OPT, oldAttrDefsOpt, newAttrDefsOpt);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAttrDefsOpt(AttrDefsOpt newAttrDefsOpt)
  {
    if (newAttrDefsOpt != attrDefsOpt)
    {
      NotificationChain msgs = null;
      if (attrDefsOpt != null)
        msgs = ((InternalEObject)attrDefsOpt).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SYMBOL_DEF_IDS__ATTR_DEFS_OPT, null, msgs);
      if (newAttrDefsOpt != null)
        msgs = ((InternalEObject)newAttrDefsOpt).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SYMBOL_DEF_IDS__ATTR_DEFS_OPT, null, msgs);
      msgs = basicSetAttrDefsOpt(newAttrDefsOpt, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.SYMBOL_DEF_IDS__ATTR_DEFS_OPT, newAttrDefsOpt, newAttrDefsOpt));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<SymbolDefId> getSymbolDefIds()
  {
    if (symbolDefIds == null)
    {
      symbolDefIds = new EObjectContainmentEList<SymbolDefId>(SymbolDefId.class, this, LidoPackage.SYMBOL_DEF_IDS__SYMBOL_DEF_IDS);
    }
    return symbolDefIds;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LidoPackage.SYMBOL_DEF_IDS__TYPE_ID:
        return basicSetTypeId(null, msgs);
      case LidoPackage.SYMBOL_DEF_IDS__ATTR_DEFS_OPT:
        return basicSetAttrDefsOpt(null, msgs);
      case LidoPackage.SYMBOL_DEF_IDS__SYMBOL_DEF_IDS:
        return ((InternalEList<?>)getSymbolDefIds()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LidoPackage.SYMBOL_DEF_IDS__TYPE_ID:
        return getTypeId();
      case LidoPackage.SYMBOL_DEF_IDS__ATTR_DEFS_OPT:
        return getAttrDefsOpt();
      case LidoPackage.SYMBOL_DEF_IDS__SYMBOL_DEF_IDS:
        return getSymbolDefIds();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LidoPackage.SYMBOL_DEF_IDS__TYPE_ID:
        setTypeId((TypeId)newValue);
        return;
      case LidoPackage.SYMBOL_DEF_IDS__ATTR_DEFS_OPT:
        setAttrDefsOpt((AttrDefsOpt)newValue);
        return;
      case LidoPackage.SYMBOL_DEF_IDS__SYMBOL_DEF_IDS:
        getSymbolDefIds().clear();
        getSymbolDefIds().addAll((Collection<? extends SymbolDefId>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.SYMBOL_DEF_IDS__TYPE_ID:
        setTypeId((TypeId)null);
        return;
      case LidoPackage.SYMBOL_DEF_IDS__ATTR_DEFS_OPT:
        setAttrDefsOpt((AttrDefsOpt)null);
        return;
      case LidoPackage.SYMBOL_DEF_IDS__SYMBOL_DEF_IDS:
        getSymbolDefIds().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.SYMBOL_DEF_IDS__TYPE_ID:
        return typeId != null;
      case LidoPackage.SYMBOL_DEF_IDS__ATTR_DEFS_OPT:
        return attrDefsOpt != null;
      case LidoPackage.SYMBOL_DEF_IDS__SYMBOL_DEF_IDS:
        return symbolDefIds != null && !symbolDefIds.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //SymbolDefIdsImpl
